<link href="/Static/mobile/css/weui.min.css" rel="stylesheet">
<script type="text/javascript" src="https://res.wx.qq.com/open/libs/weuijs/1.1.3/weui.min.js"></script>
<style>
    .weui-cells{
        font-size: 13px;
    }
    
</style>
<div id='app' style="padding-bottom:50px;" class='page'>
    <div class="weui-cells__title">订单类型</div>
    <div class="weui-cells weui-cells_radio">
        <label class="weui-cell weui-check__label" for="x2">
            <div class="weui-cell__bd">
                <p>报单<?=$gradearr[2]?></p>
            </div>
            <div class="weui-cell__ft">
                <input type="radio" class="weui-check" name="radio1" id="x2" value='2' v-model='order.grade_id'>
                <span class="weui-icon-checked"></span>
            </div>
        </label>
        <label class="weui-cell weui-check__label" for="x3">
            <div class="weui-cell__bd">
                <p>报单<?=$gradearr[3]?></p>
            </div>
            <div class="weui-cell__ft">
                <input type="radio" class="weui-check" name="radio1" id="x3" value='3' v-model='order.grade_id'>
                <span class="weui-icon-checked"></span>
            </div>
        </label>
        <label class="weui-cell weui-check__label" for="x4">
            <div class="weui-cell__bd">
                <p>报单<?=$gradearr[4]?></p>
            </div>
            <div class="weui-cell__ft">
                <input type="radio" class="weui-check" name="radio1" id="x4" value='4' v-model='order.grade_id'>
                <span class="weui-icon-checked"></span>
            </div>
        </label>
        <label class="weui-cell weui-check__label" for="x5">
            <div class="weui-cell__bd">
                <p>报单<?=$gradearr[5]?></p>
            </div>
            <div class="weui-cell__ft">
                <input type="radio" class="weui-check" name="radio1" id="x5" value='5' v-model='order.grade_id'>
                <span class="weui-icon-checked"></span>
            </div>
        </label>
    </div>
    
    <div style="display: none;" class="weui-cells__title">是否需要物流</div>
    <div style="display: none;" class="weui-cells weui-cells_radio">
        <label class="weui-cell weui-check__label" for="s11">
            <div class="weui-cell__bd">
                <p>需要物流</p>
            </div>
            <div class="weui-cell__ft">
                <input type="radio" class="weui-check" id="s11" value='1' v-model='order.is_delivery'>
                <span class="weui-icon-checked"></span>
            </div>
        </label>
        <label class="weui-cell weui-check__label" for="s12">
            <div class="weui-cell__bd">
                <p>不需要物流(进入库存)</p>
            </div>
            <div class="weui-cell__ft">
                <input type="radio"  class="weui-check" id="s12" value='0' v-model='order.is_delivery'>
                <span class="weui-icon-checked"></span>
            </div>
        </label>
    </div>
    
    <div v-if="order.is_delivery==1" class="weui-cells__title">选择商品</div>
    <div style="display:none;" v-if="order.is_delivery==1" class="weui-cells weui-cells_radio">
        <?php foreach($goodslist as $goods){ ?>
        <label class="weui-cell weui-check__label" for="s<?=$goods['goods_id']?>">
            <div class="weui-cell__bd">
                <img style="width:80px;display: inline-block;float:left;" src="<?=C('UPYUN_DOMAIN').$goods['goods_pic']?>"/>
                <p style="line-height: 80px;"><?=$goods['goods_name']?></p>
            </div>
            <div class="weui-cell__ft">
                <input type="radio" class="weui-check" id="s<?=$goods['goods_id']?>" value="<?=$goods['goods_id']?>" v-model='order.goods_id'>
                <span class="weui-icon-checked"></span>
            </div>
        </label>
        <?php } ?>
    </div>
    
    <div class="weui-cells__title">订单详情</div>
    <div class="weui-cells weui-cells_form">
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">报单用户手机号</label></div>
            <div class="weui-cell__bd">
                <input @change="getUserInfo()" v-model='order.baodan_mobile' class="weui-input" type="tel" placeholder="请输入报单用户手机号">
            </div>
        </div>
        <div  class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">数量</label></div>
            <div class="weui-cell__bd">
                <input v-model='order.number' class="weui-input" type="number" readonly placeholder="请输入数量">
            </div>
        </div>
        <div v-if="baodanUser.realname" class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">姓名</label></div>
            <div class="weui-cell__bd">
                <input v-model='baodanUser.realname' disabled class="weui-input" type="text" placeholder="">
            </div>
        </div>
        <div v-if="isnew" class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">姓名</label></div>
            <div class="weui-cell__bd">
                <input v-model='order.realname' class="weui-input" type="text" placeholder="请输入新用户姓名">
            </div>
        </div>
        <div v-if="isnew" class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">身份证</label></div>
            <div class="weui-cell__bd">
                <input v-model='order.idcard' class="weui-input" type="text" placeholder="请输入新用户身份证">
            </div>
        </div>
    </div>
    <div v-if="order.is_delivery==1" class="weui-cells__title">地区信息</div>
    <div v-show="order.is_delivery==1" class="weui-cells">
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">收货人姓名</label></div>
            <div class="weui-cell__bd">
                <input v-model='order.realname' class="weui-input" type="text" placeholder="请输入收货人姓名">
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">收货人手机</label></div>
            <div class="weui-cell__bd">
                <input v-model='order.mobile' class="weui-input" type="number" placeholder="请输入收货人手机">
            </div>
        </div>
        <div class="weui-cell weui-cell_select weui-cell_select-after">
            <div class="weui-cell__hd">
                <label class="weui-label"><span style="color:red"></span>省</label>
            </div>
            <div class="weui-cell__bd">
                <select v-model='order.province' class="weui-select" id="province" name="user_province">
                </select>
            </div>
        </div>
        <div class="weui-cell weui-cell_select weui-cell_select-after">
            <div class="weui-cell__hd">
                <label class="weui-label"><span style="color:red"></span>市</label>
            </div>
            <div class="weui-cell__bd">
                <select v-model='order.city' class="weui-select" id="city" name="user_city">
                </select>
            </div>
        </div>
        <div class="weui-cell weui-cell_select weui-cell_select-after">
            <div class="weui-cell__hd">
                <label class="weui-label"><span style="color:red"></span>区</label>
            </div>
            <div class="weui-cell__bd">
                <select v-model='order.county' class="weui-select" id="county" name="user_county">
                </select>
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">详细地址</label></div>
            <div class="weui-cell__bd">
                <input v-model='order.address' class="weui-input" type="text" placeholder="请输入详细地址">
            </div>
        </div>
    </div>
    
    <div class="weui-cells__title">费用</div>
    <div class="weui-cells weui-cells_form">
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">商品总价</label></div>
            <div class="weui-cell__bd">
                <input  class="weui-input" type="number" v-model="moneyarr.goods_money" readonly placeholder="">
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">保证金</label></div>
            <div class="weui-cell__bd">
                <input  class="weui-input" type="number" v-model="moneyarr.bzj_money" readonly placeholder="">
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">培训费</label></div>
            <div class="weui-cell__bd">
                <input  class="weui-input" type="number" v-model="moneyarr.pxf_money" readonly placeholder="">
            </div>
        </div>
        <div  class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">总费用</label></div>
            <div class="weui-cell__bd">
                <input readonly :value='moneyarr.goods_money+moneyarr.bzj_money+moneyarr.pxf_money' class="weui-input" type="number" placeholder="">
            </div>
        </div>
    </div>
    
    <?php if($memberinfo['cash_money']>0){ ?>
    <div class="weui-cells__title"><?=C("CASH_NAME")?></div>
    <div class="weui-cells weui-cells_form">
        <div class="weui-cell weui-cell_switch">
            <div class="weui-cell__bd">是否使用<?=C("CASH_NAME")?>(<?=$memberinfo['cash_money']?>)</div>
            <div class="weui-cell__ft">
                <input v-model="order.is_cash" class="weui-switch" type="checkbox">
            </div>
        </div>
    </div>
    <?php } ?>
    <?php if($memberinfo['money']>0){ ?>
    <div class="weui-cells__title"><?=C("YONGJIN_NAME")?></div>
    <div class="weui-cells weui-cells_form">
        <div class="weui-cell weui-cell_switch">
            <div class="weui-cell__bd">是否使用<?=C("YONGJIN_NAME")?>(<?=$memberinfo['money']?>)</div>
            <div class="weui-cell__ft">
                <input v-model="order.is_yongjin" class="weui-switch" type="checkbox">
            </div>
        </div>
    </div>
    <?php } ?>
    
    <div style='padding:20px 15px;'>
        <a @click='addOrder' href="javascript:;" class="weui-btn weui-btn_primary">提交</a>
    </div>
    <div style="width:100%;white-space:normal;padding:20px 15px;box-sizing: border-box;">
    <p>
    温馨提示
</p>
<p>
    1、请您准确填写注册信息，并保管好账号和密码。
</p>
<p>
    2、您的注册信息长期有效，今后登录系统时无需再次注册。
</p>
<p>
    3、您可随时登录本系统，了解有关信息。
</p>
<p>
    4、因提现需要姓名、手机号、身份证号必须真实有效，且注册后不可更改
</p>
<p>
    5：注册成功后登录账号为手机号，登录密码为身份证后六位
</p>
<p>
    祝您工作顺利并取得好成绩！
</p>
<br>
<p>
    升级温馨提示&nbsp;
</p>
<p>
    推荐升级&nbsp;
</p>
<p>
    1、全国总代推荐14900升级至全球CEO&nbsp;
</p>
<p>
    2、全国总代推荐53600升级至国际董事&nbsp;
</p>
<p>
    3、全国总代推荐156200升级至联合创始人&nbsp;
</p>
<p>
    4、全球CEO推荐38700升级至国际董事&nbsp;
</p>
<p>
    5、全球CEO推荐141300升级至联合创始人&nbsp;
</p>
<p>
    6、国际董事推荐102600升级至联合创始人&nbsp;
</p>
<p>
    <br/>
</p>
<p>
    消费升级&nbsp;
</p>
<p>
    1、当月累计报单/补货12900至全球CEO&nbsp;
</p>
<p>
    2、当月累计报单/补货34200至国际董事&nbsp;
</p>
<p>
    3、当月累计报单/补货95020至联合创始人&nbsp;
</p>
<p>
    <br/>
</p>
<p>
    直接升级&nbsp;
</p>
<p>
    1、可以直接升级补相应盒数差价
</p>
</div>
</div>

<include file="Common:nav" />
<script src="https://cdn.bootcss.com/vue/2.4.4/vue.min.js"></script>
<script src="__STATIC__mobile/js/areadata.js"></script>
<script src="__STATIC__mobile/js/myarea.js"></script>

<script>
    var app = new Vue({
        el: '#app',
        data: {
            isnew:false,
            order: {
                order_type: 1,
                grade_id: '',
                realname:'',
                mobile:'',
                number:'',
                is_delivery:0,
                province:'',
                city:'',
                county:'',
                address:'',
                baodan_mobile:'<?php echo $_GET["mobile"];?>',
                allmoney:'',
                is_cash:0,
                goods_id:1,
                is_yongjin:0
            },
            bzj:0,
            moneyarr:{
                goods_money:0,
                bzj_money:0,
                pxf_money:0,
            },
            smstext:'获取验证码',
            baodanUser:{}
        },
        mounted:function(){
            city.getcity('province','city','county','','','',1);  
        },
        watch:{
            'order.grade_id':function(val,oldval) {
                this.getprice();
            },
            'order.number':function(val,oldval) {
                this.getprice();
            }
        },
        methods: {
            numberChange: function () {
                console.log(1)
            },
            addOrder: function () {
                var self = this;
                var cfm = weui.confirm('确定提交订单吗?',function(){
                    var loading = weui.loading('loading');
                    $.ajax({
                        url:'/mobile/orderadd/baodan',
                        data: self.order,
                        type:'post'
                    }).then(function(res){
                        loading.hide();
                        if(res.ret==1) {
                            showerror(res.msg);
                        }else if(res.ret==0){
                            showsuccess(res.msg,res.url);
                        }
                    });
                    
                })
            },
            getprice: function () {
                var self = this;
                $.ajax({
                    url:'/mobile/orderadd/getbaodanprice',
                    data: self.order,
                    type:'post'
                }).then(function(res){
                    if(res.ret==1) {
                        
                    }else if(res.ret==0){
                        self.moneyarr.goods_money = res.data.goods_money;
                        self.moneyarr.bzj_money = res.data.bzj_money;
                        self.moneyarr.pxf_money = res.data.pxf_money;
                        self.order.number = res.data.number;
                    }
                });
            },
            getsmscode: function () {
                AjaxUrl('/mobile/user/getsmscode');
                this.smstext = '已发送';
            },
            getUserInfo : function () {
                var self = this;
                if(!this.order.baodan_mobile) {
                    this.order.allmoney = '';
                    this.order.number = '';
                    return;
                }
                $.get('/mobile/user/getuserinfo?uid='+this.order.baodan_mobile).then(function(res){
                    if(res.ret==1) {
                        self.isnew = true;
                    }else if(res.ret==0) {
                        self.isnew = false;
                        self.baodanUser = res.data;
                    }
                });
                this.getprice();
            }
        }
    });
</script>